package org.example.tree;

/**
 * @author liyishan
 * @date 2024/2/22 09:58
 * @apiNote
 */

public class Test00100IsSameTree {

    /**
     * 深度优先遍历    中左右
     * @param p
     * @param q
     * @return
     */
    public boolean isSameTree(TreeNode p, TreeNode q) {
        if(p == null && q == null){
            return true;
        }else if(p == null || q == null){
            return false;
        }else if(p.val != q.val){
            return false;
        }else{
            return isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
        }
    }
}
